﻿using System.Collections.Generic;
using System.Data;
using Smatime.Web.DAO.SmatimeDatasetTableAdapters;
using Smatime.Web.Models;

namespace Smatime.Web.DAO
{
    public class ListCompanyStaffCheckInRepository
        :
            BaseRepository
                <CompanyStaffTimeTable, SmatimeDataset.ListCompanyStaffCheckInDataTable,
                    ListCompanyStaffCheckInTableAdapter>
    {
        /// <summary>
        ///     Get all staff belong to a Store by the store id number.
        /// </summary>
        /// <returns></returns>
        public IEnumerable<CompanyStaffTimeTable> GetByCompanyId(long id)
        {
            using (var adapter = new ListCompanyStaffCheckInTableAdapter())
            {
                using (var table = adapter.GetDataByCompanyStaffId(id))
                {
                    var results = new List<CompanyStaffTimeTable>();
                    foreach (DataRow row in table.Rows)
                    {
                        var storeOfStaff = new CompanyStaffTimeTable();
                        storeOfStaff.FromDataRow(row);
                        results.Add(storeOfStaff);
                    }
                    return results;
                }
            }
        }
    }
}